<@override name="title">自定义菜单</@override>

<@override name="viewbody">
<!-- Page title -->
<div class="row">
    <div class="col-md-12">
        <h3 class="page-title">
            微信设置
            <small>自定义菜单</small>
        </h3>
        <ul class="page-breadcrumb breadcrumb">
            <li>
                <i class="fa fa-home"></i>
                <a href="${ctx}/admin/home">
                    首页
                </a>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <a href="#">
                    自定义菜单
                </a>
            </li>
        </ul>
    </div>
</div>
<!-- /page title -->
<div class="note note-warning">
    <p>
        注意：1级菜单最多只能3个,2级子菜单最多5个! <br/>
        添加菜单必须要在保存的基础上进行！<br/>
        生成自定义菜单,必须在已经保存的基础上进行! 所以，第一步点击保存！第二步点击生成自定义菜单!<br/>
        以http/https开头默认为链接地址,菜单类型为view，否则默认为click类型
    </p>
</div>

<div id="tip">
</div>

<div class="panel panel-default">
    <div class="panel-heading">
        菜单列表
        <a href="javascript:void(0);" class="pull-right" id="addOneLevel">添加一级菜单</a>
    </div>
    <div class="table-responsive">
        <form id="menuForm">
            <table class="table" id="menuTable">
                <thead>
                <tr>
                    <th>菜单名称</th>
                    <th>触发键值或链接地址</th>
                    <th>操作</th>
                </tr>
                </thead>
                <#if menus??>
                    <#list menus as one>
                        <tbody name="one-level" style="border-top: none;" line="${one_index}">
                        <tr>
                            <td>
                                <input type="text" class="form-control required" name="name-${one_index}" value="${one.name!}">
                                <input type="hidden" name="id-${one_index}" value="${one.id!}">
                            </td>
                            <td>
                                <#if one.menu_type??>
                                    <#if one.menu_type == 'click'>
                                        <input type="text" class="form-control" name="view-url-${one_index}" value="${one.evt!}">
                                    <#else>
                                        <input type="text" class="form-control" name="view-url-${one_index}" value="${one.url_path!}">
                                    </#if>
                                </#if>
                            </td>
                            <td style="font-size: 12px; vertical-align: middle;">
                                <a href="javascript:void(0);" name="save" level="one" line="${one_index}">保存</a>
                                <a href="javascript:void(0);" name="remove" level="one" line="${one_index}">删除</a>
                                <a href="javascript:void(0);" name="addTwoLevel" line="${one_index}">添加子菜单</a>
                            </td>
                        </tr>

                        <#if one.subs??>
                            <#list one.subs as two>
                            <tr name="two-level" line="${one_index}-${two_index}">
                                <td>
                                    <div class="form-inline">
                                        <i class="board"></i>
                                        <input type="text" class="form-control required" name="name-${one_index}-${two_index}" value="${two.name!}">
                                        <input type="hidden" name="id-${one_index}-${two_index}" value="${two.id!}">
                                    </div>
                                </td>
                                <td>
                                    <#if two.menu_type??>
                                        <#if two.menu_type == 'click'>
                                            <input type="text" class="form-control" name="view-url-${one_index}-${two_index}" value="${two.evt!}">
                                        <#else>
                                            <input type="text" class="form-control" name="view-url-${one_index}-${two_index}" value="${two.url_path!}">
                                        </#if>
                                    </#if>
                                </td>
                                <td style="font-size: 12px; vertical-align: middle;">
                                    <a href="javascript:void(0);" name="save" level="two" line="${one_index}-${two_index}">保存</a>
                                    <a href="javascript:void(0);" name="remove" level="two" line="${one_index}-${two_index}">删除</a>
                                </td>
                            </tr>
                            </#list>
                        </#if>

                        </tbody>
                    </#list>
                </#if>
            </table>

        </form>
    </div>
</div>
<div>
    <div class="btn-group">
        <button type="button" class="btn btn-info" id="create">生成自定义菜单</button>
        <button type="button" class="btn btn-info" id="revoke">撤销自定义菜单</button>
    </div>
</div>

<!-- 提示信息 -->
<script id="alert-template" type="text/x-handlers-template">
    <div class="alert {{classname}} fade in widget-inner">
        <button type="button" class="close" data-dismiss="alert">×</button>
        {{message}}
    </div>
</script>

<!-- 一级菜单模版 -->
<script id="one-level-template" type="text/x-handlers-template">
    <tbody name="one-level" style="border-top: none;" line="{{line}}">
    <tr>
        <td>
            <input type="text" class="form-control required" name="name-{{line}}">
            <input type="hidden" name="id-{{line}}">
        </td>
        <td><input type="text" class="form-control" name="view-url-{{line}}"></td>
        <td style="font-size: 12px; vertical-align: middle;">
            <a href="javascript:void(0);" name="save" level="one" line="{{line}}">保存</a>
            <a href="javascript:void(0);" name="remove" level="one" line="{{line}}">删除</a>
            <a href="javascript:void(0);" name="addTwoLevel" line="{{line}}">添加子菜单</a>
        </td>
    </tr>
    </tbody>
</script>

<!-- 二级菜单模版 -->
<script id="two-level-template" type="text/x-handlers-template">
    <tr name="two-level" line="{{line}}">
        <td>
            <div class="form-inline">
                <i class="board"></i>
                <input type="text" class="form-control required" name="name-{{line}}">
                <input type="hidden" name="id-{{line}}">
            </div>
        </td>
        <td><input type="text" class="form-control" name="view-url-{{line}}"></td>
        <td style="font-size: 12px; vertical-align: middle;">
            <a href="javascript:void(0);" name="save" level="two" line="{{line}}">保存</a>
            <a href="javascript:void(0);" name="remove" level="two" line="{{line}}">删除</a>
        </td>
    </tr>
</script>
</@override>



<@override name="viewmodule">menu</@override>
<@extends name="../../_basic/main.ftl"></@extends>

